|
this is how you should Do it
MailMessage mm = new MailMessage();
SmtpClient smtp = new SmtpClient();
mm.From = new MailAddress("cc@gmail.com");
mm.To.Add(new MailAddress("cc@its.co.za"));
mm.To.Add(new MailAddress("cc@gmail.com"));
mm.Subject = "Hello";
mm.Body = "<p>This is the E-mail Test for !Booking System</p>";
mm.IsBodyHtml = true;
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
NetworkCred.UserName = "cc@gmail.com";
NetworkCred.Password = "oops i cant give you";
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
dont forget
using System.Net.Mail;
in the Using.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
modified 30-Oct-11 2:13am.
|
|
|
|
|
Thanx for replay
but i think u just convert the code from vb.net to c#
|
|
|
|
|
the Example works Perfectly. give me your e-mail and send you a test mail.
use the http://converter.telerik.com/[^]
to convert to vb
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hello gurus,
am cofused right now.
I used this link Making TripleDES Simple in Visual Basic .NET[^]"> to do my encryption
and I have the following code section in my project to decrypt a data from database input:
datadapt = New System.Data.SqlClient.SqlDataAdapter(cmd)
ds = New DataSet
datadapt.Fill(ds)
' ds.Tables.Add(dt)
'datGrid.DataSource = ds.Tables(0)
cn.Close()
'Dim ind As Integer
Dim dc As DataColumn = New DataColumn
Dim dRow As DataRow
dRow = dt.NewRow
Dim i As Integer
Dim by As Byte
' For Each dRow In ds.Tables("Lab").Rows
For Each dRow In ds.Tables(0).Rows
For Each dc In ds.Tables(0).Columns
'If dc.DataType.ToString() = "System.String" Then
If dRow(dc).ToString = "system.Byte" Then
decData = New cTripleDES(key, iv)
Dim str As String = dRow(dc).ToString
For i = 0 To str.Length - 1
by = Convert.ToByte(str(i))
Next
'Dim by() As Byte = StrToByteArray(dRow(dc))
dRow(dc.Caption) = decData.Decrypt(by)
'deRecData = decData.Decrypt(by)
'dt.Rows.Add(deRecData)
'ds.Tables.Add(dt)
End If
Next
Next
datGrid.DataSource = ds.Tables(0)
The for loop should be able to retrieve the data in the encrypted form and then decrypt it.
I dont know if am doing the right thing, where did I get it wrong?
Thanks for ur help.
modified on Monday, July 20, 2009 6:13 AM
|
|
|
|
|
The language contructs are no different than C#. The two languages are very closely related because they both target the same MSIL.
|
|
|
|
|
Hi,
I'm pulling an inividual byte out of a byte array (I can't change the array), and that one byte needs to be treated as an SByte. As soon as the byte's value is >127 I get an overflow error as it's outside the range of SByte, and it's not automatically treated as a negative number (as it would be in C#).
I've tried CType and CSByte but no luck. The convert class appaently has the same problem.
Is there a standard way of dealing with this?
As a workaround I'm creating a temporary SByte array with one element and using Buffer.BlockCopy to copy from the original array to that, but it seems very much a hack.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi Dave,
C# doesn't flag overflows, VB.NET optionally checks for overflows, and does so by default.
Choose project properties/Compile/AdvancedCompileOptions to turn it off.
Now you can freely store a byte into an sbyte.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks once again Luc - you're becoming my personal mentor
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi again Luc,
Well I think the code is now OK - I'm not getting any error, warnings or crashes!
If you have time, I'd appreciate your comments - the article is here[^]. Thanjs again
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
The problem I found was converting numbers that cause an overflow, and thus an exception. Whilst it is true that overflow checking may be turned off, I prefer not to. The code below should be self explanatory and solve the problem.
Public Function ConvertToSByte(ByVal b As Byte) As SByte
If b > 127 Then
Return (b - 256)
Else
Return b
End If
End Function
|
|
|
|
|
i want a piece of code to draw a table first and then each cell of the table has 3 cells itself
can anybody help me???!! (((((((((
|
|
|
|
|
Just for displays? Well, host it in a WebBrowser-control
$.02
|
|
|
|
|
Pretty straightforward to do, what have you coded thus far to accomplish this?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
hi experts,
I m making one application in vb.net in which for expiration purpose,i want to add cmos date in my application.but i dont know what is the proper code?
i can have datetime.now option with me,,but it wnt work as if end user changes the windows time,the desired functionality wnt be achieved.
I hope we ll solve this problem.
Reply soon
|
|
|
|
|
A recent thread on one of the CP forums insisted BIOS datetime and Windows datetime are basically identical: change one, the other changes too.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
BIOS and system date time go hand in hand. Hence, DateTime.Now is what you can use.
You are creating "evaluation version" sort of application I guess. Using system date for checking for expiry is not that safe approach (in fact most of approaches can be broken). You can use Registry to keep note of when the application was installed and then check if it has expired.
|
|
|
|
|
hi,thanks first,
ok,as per your saying,we can use registry..but i havnt worked on it..
can you tell me solution,,
reply soon
|
|
|
|
|
I've got a C# article that's ready to publish, but I'm also wanting to include a full VB version of the code and I'm struggling with this bit (I'm not a native VBer!)
In the C# code I have an Enum, and a member of it is declared like this...
LOCL = ('L' << 24) + ('O' << 16) + ('C' << 8) + 'L' ...by using the chars as values and bit shifting to get a UInteger.
Can this be replicated in VB?
[Edit] This appears to work but it feels a bit 'hacky'. Is this the best way in VB?
LOCL = (Asc("L") << 24) + (Asc("O") << 16) + (Asc("C") << 8) + Asc("L") [/Edit]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
modified on Saturday, July 18, 2009 7:04 AM
|
|
|
|
|
Hi Dave,
two comments:
- in the C# snippet you are using characters, and just assuming they are ASCII; if they were not, their higher byte wouldn't be zero, and clash with the surrounding characters.
- in the VB snippet the intention is clear, however this time you are using strings, not characters. A VB character literal is written as "L"c , however it works as is since ASC takes the first char of a string! I don't know how ASC would react on chars that aren't ASCII though.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: assuming they are ASCII
Hi Luc,
Yeah, I'm aware of that - but in this particular sitauation they are guaranteed to be between 0 and 255 so ASCII is a safe assumption.
Would the VB be better as
LOCL = (Asc("L"c) << 24) + (Asc("O"c) << 16) + (Asc("C"c) << 8) + Asc("L"c) ?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Yes, that is what I would write, but then I don't do VB either.
Anyway, I am not sure what your intentions are, maybe it should become a little method, with a for loop, and all. And maybe all you need is an irreversible hash as in String.GetHashCode()?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks
It's actually an enum that represents the standard reference identifiers for a stratum 1 NTP server in a NTP/SNTP packet.
This part of the packet is 4 bytes, with each byte representing a character of an abreviation (zero padded if all four characters aren't required).
I have a method that does byte[34] to string conversion, but I only want to use that if it's a non standard one. The standard ones use the enum value as a key to get a more verbose string out of a dictionary value, the non standard ones just return the 4 character string.
I could just hardcode the UInt32 value into the enum directly as a number, but it's a little more descriptive in code to use the characters and bit shift, and of course there's no overhead either.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
DaveyM69 wrote: there's no overhead either
I would expect an optimizing compiler to reduce your C# expression to a single value; not sure if a VB compiler would see through the ASC function calls though.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Well enums are evaluated at compile time, so the VB compiler must or it wouldn't compile!
I'm only doing a VB version to be 'community friendly' and to revive a few of my very rusty VB skills.
(Once it's done, I think I'll ask Dave Kreskowiak to give it a look over!)
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
DaveyM69 wrote: Well enums are evaluated at compile time, so the VB compiler must or it wouldn't compile!
Maybe, maybe not. I am not sure. I do know they have to be constant expressions, however that might still defer evaluation till run-time. As an enum value, that would still be fine, since it needs to be done only once.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|